package com.hxrfid.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 会员级别折扣
 *
 * @author hxrfid
 */
@AllArgsConstructor
@Getter
public enum LevelEnum {
    ZERO("0", "普通用户", 10),
    ONE("1", "铜牌VIP", 8.8),
    TWO("2", "银牌VIP", 7.8),
    THREE("3", "金牌VIP", 6.8);

    private final String level;
    private final String name;
    private final double discount;

    /**
     * 根据级别获取折扣
     * @param level 级别
     * @return 折扣
     */
    public static double getDiscountByLevel(String level) {
        for (LevelEnum value : values()) {
            if (value.level.equals(level)) {
                return value.discount;
            }
        }
        return 1;
    }
}
